﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Cobit5.Web.MemberShip
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button_Login_Click(object sender, EventArgs e)
        {

            int result = Cobit5.BIZ.MemberShip.Membership.LoginSystem(TextBox_UserId.Text.Trim(), TextBox_Password.Text.Trim());
            switch (result)
            {
                case 0: Label_Result.Text = "输入的用户Id或密码有误"; break;
                case 1: SetSession(); break;
                case 2: Label_Result.Text = "此用户尚未被激活，请与系统管理员联系"; break;
                case 3: Label_Result.Text = "联系输错密码的次数超过系统设定，帐户已被锁定，请与系统管理员联系"; break;
                case 4: Label_Result.Text = "输入的用户Id或密码有误"; break;
                case 5:
                case 6: Label_Result.Text = "系统内部错误，请与系统管理员联系"; break;
            }
        }

        private void SetSession()
        {
            BIZ.Web.UserSession myUS = new BIZ.Web.UserSession(TextBox_UserId.Text.Trim());

            Session.Clear();
            Session["UserSession"] = myUS;
        }
    }
}